<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

/**
 *
 */
class server extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this->load->model(array('m_login', 'm_barang'));
		$this -> load -> library('xmlrpc');
		$this -> load -> library('xmlrpcs');
	}

	public function index() {
		$config['functions']['login'] = array('function' => 'server.login');
		$config['functions']['getdata'] = array('function' => 'server.getdata'); 
		$config['functions']['cekstatus'] = array('function' => 'server.cekstatus' );
		$config['functions']['cekstatuslengkap'] = array('function' => 'server.cekstatuslengkap');
		$config['functions']['ubahketerangan'] = array('function' => 'server.ubahketerangan' );
		$config['functions']['getbyid'] = array('function' => 'server.getbyid' );
		$this -> xmlrpcs -> initialize($config);
		$this -> xmlrpcs -> serve();
	}

	public function login($request)
	{
		$param = $request->output_parameters();
		$data = $this->m_login->login_client($param[0], $param[1]);
		$response = array(json_encode($data));
		return $this->xmlrpc->send_response($response);
	}

	public function getdata(){
		$data = $this->m_barang->ambil();
		$response = array(json_encode($data));
		return $this->xmlrpc->send_response($response);
	}

	public function cekstatus($request)
	{
		$param = $request->output_parameters(); //parameter e nama, pangkat, nomor_ak, nomor_senjata urut !
		$data = $this->m_barang->cek($param[0], $param[1], $param[2], $param[3]);
		$response = array(json_encode($data));
		return $this->xmlrpc->send_response($response);
	}

	public function getbyid($request)
	{
		$param = $request->output_parameters();
		$data = $this->m_barang->getbyid($param[0]);
		$response = array(json_encode($data));
		return $this->xmlrpc->send_response($response); 
	}

	public function cekstatuslengkap($request)
	{
		$param = $request->output_parameters();
		$data = $this->m_barang->ceklengkap($param[0], $param[1], $param[2], $param[3]);
		$response = array(json_encode($data));
		return $this->xmlrpc->send_response($response);
	}

	public function ubahketerangan($request) //parameter e nomor_ak dan keterangan (1/0)
	{
		$param = $request->output_parameters();
		$data = $this->m_barang->ubahketerangan($param[0], $param[1]);
		$response = array(json_encode($data));
		return $this->xmlrpc->send_response($response);
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
